package 尚硅谷juc大厂.test1;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

/**
 * Callable实现类：为什么要用Callable，因为Callable能获取到返回值而Runnable不能获取
 *
 */
@Service
@Slf4j
public class CallableServiceImpl implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        log.info("从数据库中获取数据需要2秒钟");
        TimeUnit.SECONDS.sleep(5);
        return 1024;
    }
}
